package com.peter.netty.io.bio.tomcat.http;

import java.io.InputStream;

/**
 * @Auther: 肖冬
 * @Date: 2020/9/14 20:39
 * @Description:
 */
public class XDRequest {
    private String method;
    private String url;


    public XDRequest(InputStream in) {
        try{
            //拿到HTTP协议内容
            String content = "";
            byte[] buff = new byte[1024];
            int len = 0;
            if((len = in.read(buff)) > 0){
                content = new String(buff,0,len);
            }

            String line = content.split("\\n")[0];
            String[] arr = line.split("\\s");

            this.method = arr[0];
            this.url = arr[1].split("\\?")[0];

        }catch (Exception e){
            e.printStackTrace();
        }

    }

    public String getMethod() {
        return method;
    }

    public String getUrl() {
        return url;
    }
}
